Repository navigation
consteval: Rework caller location handling - #163746
Open
theemathas wants to merge 1 commit into
Open
theemathas wants to merge 1 commit into
theemathas wants to merge 1 commit into
Conversation
theemathas
force-pushed
the
consteval-caller_location
branch
from
October 4, 2026 09:52
a401e74 to
48523ba
Compare
theemathas
commented
Oct 4, 2026
Comment on lines
+858
to
+866
| // Figure out if the callee receives a caller location argument. | ||
| // In the case where we are calling the fallback body of | ||
| // a `#[rustc_intrinsic] #[track_caller] fn`, we pretend that | ||
| // the caller doesn't pass a caller location argument (for checking ABI), | ||
| // but the caller receives a caller location argument from thin air anyway. | ||
| let callee_receives_caller_location = with_caller_location | ||
| || (instance.def.requires_caller_location(*self.tcx) | ||
| && matches!(instance.def, InstanceKind::Item(def_id) if self.tcx.intrinsic(def_id).is_some())); | ||
|
|
Contributor
Author
There was a problem hiding this comment.
This is extremely hacky, but I don't have a better idea how to handle this.
This comment has been minimized.
This comment has been minimized.
theemathas
force-pushed
the
consteval-caller_location
branch
from
October 6, 2026 14:27
48523ba to
e0647c4
Compare
This comment has been minimized.
This comment has been minimized.
theemathas
force-pushed
the
consteval-caller_location
branch
from
October 6, 2026 14:37
e0647c4 to
ab6523e
Compare
Contributor
Author
|
r? @RalfJung |
theemathas
marked this pull request as ready for review
October 6, 2026 15:43
Collaborator
|
|
Collaborator
|
Some changes occurred to the CTFE machinery
cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
Instead of walking up the call stack each time we need the caller location, we emulate the run time behavior of passing an implicit caller location argument in #[track_caller] functions. We record a representation of that argument in each frame. For inlined functions though, we still do a "stack walk" within that one frame.
theemathas
force-pushed
the
consteval-caller_location
branch
from
October 6, 2026 15:45
ab6523e to
e620c7f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of walking up the call stack each time we need the caller location, we emulate the run time behavior of passing an implicit caller location argument in
#[track_caller]functions. We record a representation of that argument in each frame. For inlined functions though, we still do a "stack walk" within that one frame.This PR is a prerequisite for #163396